﻿using System.Web.Mvc;

namespace GabageFactory.Models
{
    public static class HtmlHelperExtension
    {
        public static string CutString(this HtmlHelper helper, string source, int length = 30, string subfix = "...")
        {
            return CutString(source, length, subfix);
        }

        public static string CutString(string source, int length = 15, string subfix = "...")
        {
            if (string.IsNullOrEmpty(source) || source.Length <= length)
            {
                return source;
            }
            else
            {
                return source.Substring(0, length) + subfix;
            }
        }
    }
}